|
1
|
|
|
/** global: Analytics */ |
|
2
|
|
|
/** global: google */ |
|
3
|
|
|
/** |
|
4
|
|
|
* BaseChart |
|
5
|
|
|
*/ |
|
6
|
|
|
Analytics.reports.BaseChart = Garnish.Base.extend( |
|
|
|
|
|
|
7
|
|
|
{ |
|
8
|
|
|
$chart: null, |
|
9
|
|
|
$graph: null, |
|
10
|
|
|
|
|
11
|
|
|
localeDefinition: null, |
|
12
|
|
|
|
|
13
|
|
|
type: null, |
|
14
|
|
|
chart: null, |
|
15
|
|
|
chartOptions: null, |
|
16
|
|
|
data: null, |
|
17
|
|
|
period: null, |
|
18
|
|
|
options: null, |
|
19
|
|
|
visualization: null, |
|
20
|
|
|
drawing: false, |
|
21
|
|
|
|
|
22
|
|
|
init: function($element, data, localeDefinition, chartLanguage) { |
|
23
|
|
|
this.visualization = new Analytics.Visualization( |
|
24
|
|
|
{ |
|
25
|
|
|
chartLanguage: chartLanguage, |
|
26
|
|
|
onAfterInit: $.proxy(function() { |
|
27
|
|
|
this.$chart = $element; |
|
28
|
|
|
this.$chart.html(''); |
|
29
|
|
|
this.$graph = $('<div class="chart" />').appendTo(this.$chart); |
|
30
|
|
|
this.data = data; |
|
31
|
|
|
this.localeDefinition = localeDefinition; |
|
32
|
|
|
|
|
33
|
|
|
if (typeof(this.data.chartOptions) != 'undefined') { |
|
34
|
|
|
this.chartOptions = this.data.chartOptions; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
if (typeof(this.data.type) != 'undefined') { |
|
38
|
|
|
this.type = this.data.type; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
if (typeof(this.data.period) != 'undefined') { |
|
42
|
|
|
this.period = this.data.period; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
this.addListener(Garnish.$win, 'resize', 'resize'); |
|
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
this.initChart(); |
|
48
|
|
|
|
|
49
|
|
|
this.draw(); |
|
50
|
|
|
|
|
51
|
|
|
if (typeof(this.data.onAfterInit) != 'undefined') { |
|
52
|
|
|
this.data.onAfterInit(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
}, this) |
|
56
|
|
|
}); |
|
57
|
|
|
}, |
|
58
|
|
|
|
|
59
|
|
|
addChartReadyListener: function() { |
|
60
|
|
|
google.visualization.events.addListener(this.chart, 'ready', $.proxy(function() { |
|
61
|
|
|
this.drawing = false; |
|
62
|
|
|
|
|
63
|
|
|
if (typeof(this.data.onAfterDraw) != 'undefined') { |
|
64
|
|
|
this.data.onAfterDraw(); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
}, this)); |
|
68
|
|
|
}, |
|
69
|
|
|
|
|
70
|
|
|
initChart: function() { |
|
71
|
|
|
this.$graph.addClass(this.type); |
|
72
|
|
|
}, |
|
73
|
|
|
|
|
74
|
|
|
draw: function() { |
|
75
|
|
|
if (!this.drawing) { |
|
76
|
|
|
this.drawing = true; |
|
77
|
|
|
|
|
78
|
|
|
if (this.dataTable && this.chartOptions) { |
|
79
|
|
|
|
|
80
|
|
|
this.chart.draw(this.dataTable, this.chartOptions); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
}, |
|
84
|
|
|
|
|
85
|
|
|
resize: function() { |
|
86
|
|
|
if (this.chart && this.dataTable && this.chartOptions) { |
|
87
|
|
|
this.draw(this.dataTable, this.chartOptions); |
|
88
|
|
|
} |
|
89
|
|
|
}, |
|
90
|
|
|
}); |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.